package lsl.leetCode.year2023.test0206;

/**剑指 Offer 58 - II. 左旋转字符串
 * @author Zed
 * @description
 * @date 2023/2/6 18:51
 */
public class offer58 {
    public static void main(String[] args) {
        String s = "lrloseumgh";
        int k = 6;
        System.out.println(reverseLeftWords(s, k));
    }

    public static String reverseLeftWords(String s, int n) {
        int length = s.length();
        char[] arr = new char[s.length()];
        int index = 0;
        int back = n;
        int pre = 0;
        while (index < length) {
            if (index < n) {
                arr[length - index - 1] = s.charAt(back - 1);
            } else {
                arr[pre] = s.charAt(index);
                pre++;
            }
            back--;
            index++;
        }
        return String.valueOf(arr);
    }
}
